/*
 * Camera.h
 *
 *  Created on: Oct 16, 2012
 *      Author: travis
 */

#pragma once

#define PI 				3.14159265

#ifdef _WIN32 
#include <windows.h>
#include "SDL.h"
#else
#include "SDL/SDL.h"
#endif

#include "../Terrain.h"

#include <math.h>
#include "Timer.h"
#include "World.h"
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "../octree/Box.h"
#include "../engine/engineSettings.h"

namespace Camera
{

extern glm::vec3 CamPos;

class Camera
{
public:
	Camera(Timer *_fps);
	virtual ~Camera();

	void control(SDL_Event *event);
	void update();
	void setupView();

	// set camera position looking at point on map
	// pos in 2D -> x and z coordinate in 3D
	// second parameter is zoom
	void lookAt(glm::vec2 pos, float _z);
	// overloaded function, second variant without zoom parameter
	void lookAt(glm::vec2 pos);

	float getZoom();
	Terrain::Terrain*& getTerrain();
	void setTerrain(Terrain::Terrain*& terrain);
	float getWaterHigh() const;
	void setWaterHigh(float waterHigh);
	const glm::vec3& getCamPos() const;
	void setCamPos(const glm::vec3& camPos);
	const glm::vec3& getOrigin() const;
	void setOrigin(const glm::vec3& origin);
	float getAngle() const;
	void setAngle(float angle);

private:
	Timer *fps;
	float time;
	float STEP;
	float zoomspeed, xspeed, yspeed;
	int az, ay, ax;
	float angle;

	Terrain::Terrain *terrain;

	// new
	glm::vec3 camPos; // camera position
	glm::vec3 origin; // point on map (center of screen)
	float zoom; // zoom
	float oldHigh;

	float waterHigh;
	//-----
};

extern Camera *camera;

void initCamera(Timer *fps);
void deleteCamera();

}
